package smartlifev30.com.sdk.util;

import android.support.annotation.NonNull;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.parser.Feature;

import java.lang.reflect.Type;

/**
 * Created by uesr on 2018/6/29.
 */

public class JsonUtil {

    public static String toString(@NonNull Object obj) {
        return JSON.toJSONString(obj);
    }

    public static <T> T toObject(@NonNull String jsonStr, @NonNull Class<T> clazz) {
        T object = null;
        try {
            object = JSON.parseObject(jsonStr, clazz);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return object;
    }

}
